package Chapter04;

public class Demo_while {
	public static void main(String[] args) {
		int i=0,x=1;
		while(x<=40) {
		if(x%3==0) {i=i+x;System.out.print(x+" ");}
		else if(x/10==3) {i=i+x;System.out.print(x+" ");}
		else if(x%10==3) {i=i+x;System.out.print(x+" ");}
			
			
			x++;
			
			
		}
		System.out.println(i);
	}

}
